package com.tanhua.server.controller;

import com.tanhua.model.LinHun.Suo;
import com.tanhua.model.vo.BaogaoVo;
import com.tanhua.model.vo.SoulVO;
import com.tanhua.server.interceptor.UserHolder;
import com.tanhua.server.service.TestSoulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/testSoul")
public class TestSoulContorller {


    @Autowired
    private TestSoulService testSoulService;
    //问卷
    @GetMapping
    public ResponseEntity testSoul(){
        List<SoulVO> soul = testSoulService.testSoul();
        return ResponseEntity.ok(soul);
    }
    //提交
    @PostMapping
    public ResponseEntity tiesSoul(@RequestBody Map<String,List<Suo>> answers){
        List<Suo> list = answers.get("answers");
        String vo=  testSoulService.tiesSoul(list);
        return ResponseEntity.ok(vo);
    }
    //查看结果  /testSoul/report/:id
    @GetMapping("/report/{id}")
    public ResponseEntity report(@PathVariable("id")String id){
        BaogaoVo baogaoVo = testSoulService.report(id);
        return ResponseEntity.ok(baogaoVo);
    }
}
